<?php
namespace Common\Controller;

class AdminBaseController extends BaseController{
    public function _initialize(){
        parent::_initialize();

        if(empty(session('user.uid')) && empty(session('user.account'))){
            $this -> error('您没有登录!<br>',U('admin/login/index'),2);
            exit;
        }

        //  验证权限
        $auth = new \Think\Auth();
        $rule_name = MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;
        $uid = session('user.uid');
        if(!$auth->check($rule_name,$uid) && $uid != 1){
            $this->error('您没有权限访问！');
        };
    }
}